package com.achao.config;

import com.achao.interceptor.feign.CustomFeignInterceptor;
import feign.Contract;
import feign.Logger;
import feign.Request;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: achao
 * @DateTime: 2022/10/15 23:17
 * @Description:
 *    1.全局配置: 使用@Configuration
 *    2.局部配置: 不要使用@Configuration
 */

@Configuration
public class OpenFeignConfig {

    /**
     * 开启日志
     * @return
     */
    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

    /**
     * 契约配置,支持Feign的注解
     * @return
     */
    //@Bean
    //public Contract feignContract(){
    //    return new Contract.Default();
    //}

    /**
     * 超时时间配置
     * @return
     */
    @Bean
    public Request.Options options(){
        return new Request.Options(5000,10000);
    }

    /**
     * 自定义拦截器
     * @return
     */
    @Bean
    public CustomFeignInterceptor feignAuthRequestInterceptor(){
        return new CustomFeignInterceptor();
    }

}
